<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  
  <meta name="generator" content="Hugo 0.98.0" />

  
  <meta name="description" content="走在通往幸福的路上">
  

  
  <link rel="apple-touch-icon" sizes="180x180" href="https://blog.v5u.win/apple-touch-icon.png">

  
  <link rel="icon" type="image/png" sizes="32x32" href="https://blog.v5u.win/favicon-32x32.png">

  
  <link rel="icon" type="image/png" sizes="16x16" href="https://blog.v5u.win/favicon-16x16.png">

  
  <link rel="manifest" href="https://blog.v5u.win/site.webmanifest">

  
  <link rel="mask-icon" href="https://blog.v5u.win/safari-pinned-tab.svg" color="">

  <meta name="msapplication-TileColor" content="">

  <meta name="theme-color" content="">

  
  <link rel="stylesheet" href="https://blog.v5u.win/css/bootstrap.min.css" />

  
  <title>k8s在Mac上的安装和使用 | 为吾优</title>
  

  <style>
body {
  min-width: 300px;
}

.custom-navbar {
  margin-bottom: 1em;
  height: 60px;
}

.custom-navbar a {
  display: inline-block; 
  padding: 18px 0;
  margin-right: 1em; 
  font-weight: bold; 
}

.custom-navbar a:hover,
.custom-navbar a:focus {
  text-decoration: none; 
}

@media print {
  .custom-navbar {
    display: none;
  }
}

article {
  padding-bottom: 1em;
}

img {
  max-width: 100%;
}


body {
  background-color: #fff;
}



body {
  color: #212529;
}



a {
  color: #007bff;
}



a:hover,
a:focus {
  color: #0056b3;
}



.custom-navbar {
  background-color: #212529;
}



.custom-navbar a {
  color: rgba(255,255,255,.75);
}



.custom-navbar a:hover,
.custom-navbar a:focus {
  color: rgba(255,255,255,1);
}



.container {
  max-width: 800px;
}





</style>
</head>

<body>
  <nav class="custom-navbar">
  <div class="container">
    
    <a href="/">文章</a>
    
    <a href="/tags/">标签</a>
    
    <a href="/about/">关于</a>
    
    <a href="/index.xml">RSS</a>
    
  </div>
</nav>
  
  <div class="container">
    <article>
      <h1>k8s在Mac上的安装和使用</h1>
<h1 id="安装">安装</h1>
<p>在Mac下安装前提条件，已经安装好了docker desktop，并修改了代理源 <a href="https://registry.docker-cn.com">https://registry.docker-cn.com</a>。</p>
<p>直接在docker桌面端开启k8s是没用的，一直提示 kubernetes is starting… 😢 我竟然不知道，这样子持续了n天。​</p>
<h2 id="自己手动编译安装-k8s">自己手动编译安装 k8s</h2>
<ul>
<li>
<p>git clone <a href="https://github.com/maguowei/k8s-docker-for-mac.git">https://github.com/maguowei/k8s-docker-for-mac.git</a></p>
</li>
<li>
<p>cd k8s-docker-for-mac/</p>
</li>
<li>
<p>./load_images.sh</p>
</li>
</ul>
<h2 id="安装minikube">安装minikube</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#75715e"># install minikube</span>
</span></span><span style="display:flex;"><span>$ brew cask install minikube
</span></span><span style="display:flex;"><span>$ brew install docker-machine-driver-xhyve
</span></span><span style="display:flex;"><span><span style="color:#75715e"># docker-machine-driver-xhyve need root owner and uid</span>
</span></span><span style="display:flex;"><span>$ sudo chown root:wheel <span style="color:#66d9ef">$(</span>brew --prefix<span style="color:#66d9ef">)</span>/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
</span></span><span style="display:flex;"><span>$ sudo chmod u+s <span style="color:#66d9ef">$(</span>brew --prefix<span style="color:#66d9ef">)</span>/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
</span></span></code></pre></div><p>最后启动minikube</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#75715e"># start minikube.</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># http proxy is required in China</span>
</span></span><span style="display:flex;"><span>$ minikube start --docker-env HTTP_PROXY<span style="color:#f92672">=</span>http://proxy-ip:port --docker-env HTTPS_PROXY<span style="color:#f92672">=</span>http://proxy-ip:port --vm-driver<span style="color:#f92672">=</span>xhyve
</span></span></code></pre></div><h2 id="ubuntu">Ubuntu</h2>
<p>安装 kubeadm kubectl kubelet 三个包</p>

    </article>
  </div>

  
  
  

  
</body>

</html>